package com.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.google.gson.reflect.TypeToken;
import com.util.GsonUtil;

import net.sf.json.JSONObject;

@Controller
@RequestMapping("/util")
public class UtilsController extends BaseAction {
	/**
	 * 获取城市信息
	 * GetCityList
	 * @param request
	 * @return
	 */
	@RequestMapping("/getCityList")
    public JSONObject getCityList(HttpServletRequest request){
		JSONObject jsonObject = new JSONObject();
		Map<String,Object> promap = new HashMap<String,Object>();
		String resultJson=getHttpJson("Logistics/ZDK/GetCityList",GsonUtil.toJson(promap),request,false);
		if(resultJson!=null){
			jsonObject = GsonUtil.fromJson(resultJson,new TypeToken<Map<String, Object>>(){}.getType());
			return jsonObject;
		}
		return null;
    }


	/**
	 * 获取省或直辖市信息
	 * GetProvince
	 * @param request
	 * @return
	 */
	@RequestMapping("/getProvince")
	public JSONObject getProvince(HttpServletRequest request){
		JSONObject jsonObject = new JSONObject();
		Map<String,Object> promap = new HashMap<String,Object>();
		String resultJson=getHttpJson("Logistics/ZDK/GetProvince",GsonUtil.toJson(promap),request,false);
		if(resultJson!=null){
			jsonObject = GsonUtil.fromJson(resultJson,new TypeToken<Map<String, Object>>(){}.getType());
			return jsonObject;
		}
		return null;
	}

	/**
	 * 获取省或直辖市信息
	 * GetProvince
	 * @param request
	 * @return
	 */
	@RequestMapping("/getCityOfProvince")
	public JSONObject getCityOfProvince(HttpServletRequest request){
		JSONObject jsonObject = new JSONObject();
		Map<String,Object> promap = new HashMap<String,Object>();
		String resultJson=getHttpJson("Logistics/ZDK/GetCityOfProvince",GsonUtil.toJson(promap),request,false);
		if(resultJson!=null){
			jsonObject = GsonUtil.fromJson(resultJson,new TypeToken<Map<String, Object>>(){}.getType());
			return jsonObject;
		}
		return null;
	}

	/**
	 * 获取区信息
	 * GetProvince
	 * @param request
	 * @return
	 */
	@RequestMapping("/getDistrict")
	public JSONObject getDistrict(HttpServletRequest request){
		JSONObject jsonObject = new JSONObject();
		Map<String,Object> promap = new HashMap<String,Object>();
		String resultJson=getHttpJson("Logistics/ZDK/GetDistrict",GsonUtil.toJson(promap),request,false);
		if(resultJson!=null){
			jsonObject = GsonUtil.fromJson(resultJson,new TypeToken<Map<String, Object>>(){}.getType());
			return jsonObject;
		}
		return null;
	}


}
